package m.store.model;

import m.base.model.StoreInfo;
import m.base.model.UserInfo;
import m.common.model.*;
import m.common.model.type.FieldType;
import m.common.model.util.ModelQueryList;
import m.common.model.util.QueryCondition;
import manage.model.StatusModel;

import java.util.List;
import java.util.stream.Collectors;

@TableMeta(name = "ts_guest_info", description = "客户信息")
public class GuestInfo extends StatusModel implements MigrationModel {
    @Override
    public List<String> migrationOidList(String storeOid) throws Exception {
        return ModelQueryList.getModelList(this.getClass(),new String[]{"oid"},null,
                        QueryCondition.eq("store.oid",storeOid))
                .stream().map(Model::getOid).collect(Collectors.toList());
    }
    @LinkTableMeta(name="store_oid",table= StoreInfo.class,description="所属商户")
    private StoreInfo store;
    @LinkTableMeta(name="input_user_oid",table= UserInfo.class,description="录入用户")
    private UserInfo inputUser;
    @LinkTableMeta(name="manage_user_oid",table= UserInfo.class,description="管理用户")
    private UserInfo manageUser;
    @FieldMeta(name="type",type= FieldType.STRING,description="类型",dictOption = "A:公司,B:个人")
    private String type;
    public final static String Type_Company="A";
    public final static String Type_People="B";
    @FieldMeta(name="name",type= FieldType.STRING,length=50,description="名称")
    private String name;
    @FieldMeta(name="duty_user",type= FieldType.STRING,length=20,description="负责人")
    private String dutyUser;
    @FieldMeta(name="tel",type= FieldType.STRING,length=20,description="联系电话")
    private String tel;
    @FieldMeta(name="address",type= FieldType.STRING,length=300,description="地址")
    private String address;
    @FieldMeta(name = "description",type = FieldType.STRING,length = 1000,description = "描述")
    private String description;

    //冗余信息
    @FieldMeta(name="stock_amount",type= FieldType.DOUBLE,defaultValue = "0",description="入库金额")
    private Double stockAmount;
    @FieldMeta(name="stock_pay_amount",type= FieldType.DOUBLE,defaultValue = "0",description="入库已结金额")
    private Double stockPayAmount;
    @FieldMeta(name="sale_amount",type= FieldType.DOUBLE,defaultValue = "0",description="出库金额")
    private Double saleAmount;
    @FieldMeta(name="sale_income_amount",type= FieldType.DOUBLE,defaultValue = "0",description="出库已结金额")
    private Double saleIncomeAmount;
    @FieldMeta(name="surplus_amount",type= FieldType.DOUBLE,defaultValue = "0",description="剩余金额|出库金额-出库已结金额-(入库金额-入库已结金额)")
    private Double surplusAmount;

    public UserInfo getManageUser() {
        return manageUser;
    }

    public void setManageUser(UserInfo manageUser) {
        this.manageUser = manageUser;
    }

    public String getDutyUser() {
        return dutyUser;
    }

    public void setDutyUser(String dutyUser) {
        this.dutyUser = dutyUser;
    }

    public UserInfo getInputUser() {
        return inputUser;
    }

    public void setInputUser(UserInfo inputUser) {
        this.inputUser = inputUser;
    }

    public StoreInfo getStore() {
        return store;
    }

    public void setStore(StoreInfo store) {
        this.store = store;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Double getStockAmount() {
        return stockAmount;
    }

    public void setStockAmount(Double stockAmount) {
        this.stockAmount = stockAmount;
    }

    public Double getStockPayAmount() {
        return stockPayAmount;
    }

    public void setStockPayAmount(Double stockPayAmount) {
        this.stockPayAmount = stockPayAmount;
    }

    public Double getSaleIncomeAmount() {
        return saleIncomeAmount;
    }

    public void setSaleIncomeAmount(Double saleIncomeAmount) {
        this.saleIncomeAmount = saleIncomeAmount;
    }

    public Double getSaleAmount() {
        return saleAmount;
    }

    public void setSaleAmount(Double saleAmount) {
        this.saleAmount = saleAmount;
    }


    public Double getSurplusAmount() {
        return surplusAmount;
    }

    public void setSurplusAmount(Double surplusAmount) {
        this.surplusAmount = surplusAmount;
    }
}
